package servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/group/equipment/Equipment_edit")
public class EquipmentEditOrAdd extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public EquipmentEditOrAdd(){
        super();
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=UTF-8");
        String eq_id = req.getParameter("id");
        req.setAttribute("id",eq_id);
        // 在这里用这个在jsp页面竟然可以用getParameter来获取
        // 重定向解决
        req.getRequestDispatcher("equipment_addOrEdit.jsp?id=" + eq_id).forward(req,resp);
    }
}
